<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>商品评论</title>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
</head>
<body>
<div class="layui-panel" style="padding: 8px;">
    <fieldset class="layui-elem-field layui-border-blue">
        <legend>搜索信息</legend>
        <form class="layui-form layui-form-pane" style="margin: 20px;">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">用户id</label>

                    <div class="layui-input-inline">
                        <input class="layui-input" type="text" name="name" autocomplete="off" />
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">商品id</label>

                    <div class="layui-input-inline">
                        <input class="layui-input" type="text" name="name" autocomplete="off" />
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <a class="layui-btn layui-btn-primary" lay-submit="" lay-filter="searchBtn">
                            <i class="layui-icon layui-icon-search"></i>
                            查找
                        </a>
                    </div>
                </div>
            </div>
        </form>
    </fieldset>
    <div>
        <table id="commentTable" lay-filter="commentTable" class="layui-table layui-form"></table>
    </div>
</div>
<script id="tool" type="text/html">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
</script>
<script id="tableBar" type="text/html">

    <!--<a class="layui-btn layui-btn-danger layui-btn-md" lay-event="delete">
        <i class="layui-icon layui-icon-delete"></i>
        删除
    </a>-->
</script>

<script id="swichType" type="text/html">

		</script>

<script id="swichStatus" type="text/html">

		</script>
<script>

    var data=[];
    var $;
    layui.use(['form','layer','table','jquery'],function(){
        var form = layui.form,table = layui.table;
        var $=layui.jquery;

        //加载表格
        table.render({
            elem:'#commentTable',
            height:'full-160',
            toolbar:'#tableBar',
            url:'/comment/ct/find',
            tree:{
                iconIndex:2,//图表列的下标值
                isPidData:true,//是否为树形
                idName:'id',//id唯一值的列属性名
                pidName:'pid',//父id值的列属性名
                openName:true//是否默认打开
            },
            cols:[
                [

                {type:'checkbox',fixed:'left'},
                {type:'numbers',fixed:'left'},
                {field:'id',title:'评论id',width:80,align: 'center'},
                {field:'gid',title:'商品id',width:100,align: 'center'},
                {field:'mname',title:'用户名',width:100,align: 'center'},
                {field:'fraction',title:'打分',width:100,align: 'center'},
                {field:'content',title:'评论内容',align: 'center'},
                {field:'up',title:'点赞数',width: 80,align: 'center'},
                {field:'picture',title:'评论图片',width:180,align: 'center'},
                {field:'updateTime',title:'时间',width:180,align: 'center'},
                {fixed:'right',title:'操作',width:100,align:'center',toolbar:'#tool'},
            ]
            ],
            data:data
        })

        //监听搜索按钮
        form.on('submit(searchBtn)',function(data){
            var dataForm = data.field;

            alert();
            console.log(dataForm);
        })


        active={
            deleteConfirm:function (ids){

                layer.confirm('确定删除该记录?',function (index){

                    if (index>0){
                        $.ajax({
                            type:'post',
                            url: '/comment/ct/delete',
                            data:{
                                id:ids
                            },
                            dataType:'json',
                            success:function (result){
                                layer.msg(result.msg);
                                if (result.is){
                                    layui.table.reload('table');
                                }
                            }
                        })
                    }
                })

            }
        }



  table.on('tool(commentTable)',function (obj){

      var event = obj.event;
       if ('delete' == event){
          var ids = obj.data.id;
          active.deleteConfirm(ids);
      }
  })

    });
</script>


</body>
</html>
